Skip to content

feat: reprepare and retry prepared statements#970

Open
dowzhong wants to merge 9 commits into
pgdogdev:mainfrom
dowzhong:feat/iss934-reprepare-statements
Open

feat: reprepare and retry prepared statements#970
dowzhong wants to merge 9 commits into
pgdogdev:mainfrom
dowzhong:feat/iss934-reprepare-statements

Conversation

@dowzhong

@dowzhong dowzhong commented May 8, 2026

Copy link
Copy Markdown

#943

My attempt at implementing automatic reprepare+retry of prepared statements that hit a cache error.

I thought the place place to do this would be in the server impl. That way, we can avoid dealing with sharding and duplicating the retry logic at different points. Please let me know if I should move it elsewhere though.

The main piece of work here is a small state machine in each server that keeps track of what the current batch of messages are, and if they've returned with expected. That way, we can know which messages we need to retry, and which messages we shouldn't send again. An example being

Parse
Describe
--- later ---
Describe
Bind <-- cache error happens here
Execute
Sync

In this case, we want to reprepare and only retry from bind onwards.

@CLAassistant

CLAassistant commented May 8, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@dowzhong dowzhong marked this pull request as draft May 8, 2026 15:48
@codecov

codecov Bot commented May 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.41270% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pgdog/src/backend/server_state.rs 98.69% 5 Missing ⚠️
pgdog/src/backend/server.rs 98.73% 3 Missing ⚠️
pgdog/src/backend/prepared_statements.rs 66.66% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@dowzhong dowzhong marked this pull request as ready for review May 11, 2026 09:59
@dowzhong

Copy link
Copy Markdown
Author

weird, the python integration tests locally for me

@meskill

meskill commented May 20, 2026

Copy link
Copy Markdown
Contributor

weird, the python integration tests locally for me

integration tests are flaky sometimes, there are no errors after the restart

@dowzhong

Copy link
Copy Markdown
Author

Thanks for that, just resolved the conflicts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants